/**
 *   @file TreeNode.h
 */
#ifndef _TREENODE_H_
#define _TREENODE_H_

#include "../../common/BaseObject.h"

namespace cppflib
{

namespace collections
{

namespace tree
{

/**
 *  A class to represent a tree node. Users should inherit from this class, implement the 
 *  pure virtual functions and finally add custom data in the derived class.
 */
class _DLLAPI TreeNode : public BaseObject
{
public:
    TreeNode(void);
    virtual ~TreeNode(void);

    /**
     *   A comparison function called by a Tree class.
     *
     *   @param [in] treeNode -- a node to be compared with 
     *
     *   @return 0 -- both with the same key
     *   @return < 0 -- key of this node is "less" than pTreeNode
     *   @return > 0 -- key of this node is "greater" than pTreeNode
     */
    virtual int Compare(const TreeNode &treeNode) = 0;
    /**
     *   Copy content from another node to this node
     */
    virtual void CopyFromNode(const TreeNode &treeNode) = 0;

    TreeNode * GetParent();
    TreeNode * GetLeftChild();
    TreeNode * GetRightChild();
    int GetChildNum();
    bool HasNoParent();
    int GetDepth();

protected:
    TreeNode * m_pParent;     ///< points to parent
    TreeNode * m_leftChild;   ///< points to left child
    TreeNode * m_rightChild;  ///< points to right child

    friend class BinTree;
};

}  // end of namespace tree

}  // end of namespace collections

}  // end of namespace cppflib


#endif
